import { AUTH_USER, UNAUTH_USER, AUTH_ERROR, FETCH_MESSAGE } from '../actions/types'
const auth = (state={}, action) => {
    switch (action.type) {
      case AUTH_USER:
        return {...state, error: '', authenticated: true, info: action.payload}
      case UNAUTH_USER:
        localStorage.removeItem('info');
        return {...state, authenticated: false}
      case AUTH_ERROR:
        return {...state, error: action.payload}
      case FETCH_MESSAGE:
        return {...state, message: action.payload}
      default:
        return state;
    }
}

export default auth;